<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
  </head>
  <body>
    <script>
      var a = 10
      var foo = {
        a: 20,
        fn: function() {
          // console.log(this)
          console.log(this.a)
        }
      }
      var bar = {
        a: 30
      }
      foo.fn() // 20
      foo.fn.apply() // 10 如果不传值或者null得话，this就是window(若参数为空，默认指向全局对象)
      foo.fn.call() // 10
      foo.fn.apply(foo) // 20
      foo.fn.apply(bar) // 30
    </script>
  </body>
</html>
